home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Sample Code / Overview / Sample / Sample.r < prev    next >
Encoding:
Text File  |  1994-11-18  |  6.3 KB  |  287 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------
  2. #
  3. #    Apple Macintosh Developer Technical Support
  4. #
  5. #    MultiFinder-Aware Simple Sample Application
  6. #
  7. #    Sample
  8. #
  9. #    Sample.r    -    Rez Source
  10. #
  11. #    Copyright © 1989 Apple Computer, Inc.
  12. #    All rights reserved.
  13. #
  14. #    Versions:    
  15. #                1.00                08/88
  16. #                1.01                11/88
  17. #                1.02                04/89
  18. #                1.03                06/89
  19. #                1.04                06/92
  20. #
  21. #    Components:
  22. #                Sample.p            June 1, 1989
  23. #                Sample.c            June 1, 1989
  24. #                SampleInit.c        June 2, 1992
  25. #                Sample.a            June 1, 1989
  26. #                Sample.inc1.a        June 1, 1989
  27. #                SampleMisc.a        June 1, 1989
  28. #                Sample.r            June 1, 1989
  29. #                Sample.h            June 1, 1989
  30. #                PSample.make        June 1, 1989
  31. #                CSample.make        June 1, 1989
  32. #                ASample.make        June 1, 1989
  33. #                CSample.π            June 2, 1992
  34. #                CSample.π.rsrc        June 2, 1992
  35. #
  36. #    Sample is an example application that demonstrates how to
  37. #    initialize the commonly used toolbox managers, operate 
  38. #    successfully under MultiFinder, handle desk accessories, 
  39. #    and create, grow, and zoom windows.
  40. #
  41. #    It does not by any means demonstrate all the techniques 
  42. #    you need for a large application. In particular, Sample 
  43. #    does not cover exception handling, multiple windows/documents, 
  44. #    sophisticated memory management, printing, or undo. All of 
  45. #    these are vital parts of a normal full-sized application.
  46. #
  47. #    This application is an example of the form of a Macintosh 
  48. #    application; it is NOT a template. It is NOT intended to be 
  49. #    used as a foundation for the next world-class, best-selling, 
  50. #    600K application. A stick figure drawing of the human body may 
  51. #    be a good example of the form for a painting, but that does not 
  52. #    mean it should be used as the basis for the next Mona Lisa.
  53. #
  54. #    We recommend that you review this program or TESample before 
  55. #    beginning a new application.
  56. ------------------------------------------------------------------------------*/
  57.  
  58.  
  59. #include "Types.r"
  60.  
  61. #include "Sample.h"
  62.  
  63.  
  64. /* this is a definition for a resource which contains only a rectangle */
  65.  
  66. type 'RECT' {
  67.     rect;
  68. };
  69.  
  70.  
  71. /* we use an MBAR resource to conveniently load all the menus */
  72.  
  73. resource 'MBAR' (rMenuBar, preload) {
  74.     { mApple, mFile, mEdit, mLight };    /* four menus */
  75. };
  76.  
  77.  
  78. resource 'MENU' (mApple, preload) {
  79.     mApple, textMenuProc,
  80.     AllItems & ~MenuItem2,    /* Disable dashed line, enable About and DAs */
  81.     enabled, apple,
  82.     {
  83.         "About Sample…",
  84.             noicon, nokey, nomark, plain;
  85.         "-",
  86.             noicon, nokey, nomark, plain
  87.     }
  88. };
  89.  
  90. resource 'MENU' (mFile, preload) {
  91.     mFile, textMenuProc,
  92.     MenuItem12,                /* enable Quit only, program enables others */
  93.     enabled, "File",
  94.     {
  95.         "New",
  96.             noicon, "N", nomark, plain;
  97.         "Open",
  98.             noicon, "O", nomark, plain;
  99.         "-",
  100.             noicon, nokey, nomark, plain;
  101.         "Close",
  102.             noicon, "W", nomark, plain;
  103.         "Save",
  104.             noicon, "S", nomark, plain;
  105.         "Save As…",
  106.             noicon, nokey, nomark, plain;
  107.         "Revert",
  108.             noicon, nokey, nomark, plain;
  109.         "-",
  110.             noicon, nokey, nomark, plain;
  111.         "Page Setup…",
  112.             noicon, nokey, nomark, plain;
  113.         "Print…",
  114.             noicon, nokey, nomark, plain;
  115.         "-",
  116.             noicon, nokey, nomark, plain;
  117.         "Quit",
  118.             noicon, "Q", nomark, plain
  119.     }
  120. };
  121.  
  122. resource 'MENU' (mEdit, preload) {
  123.     mEdit, textMenuProc,
  124.     NoItems,                /* disable everything, program does the enabling */
  125.     enabled, "Edit",
  126.      {
  127.         "Undo",
  128.             noicon, "Z", nomark, plain;
  129.         "-",
  130.             noicon, nokey, nomark, plain;
  131.         "Cut",
  132.             noicon, "X", nomark, plain;
  133.         "Copy",
  134.             noicon, "C", nomark, plain;
  135.         "Paste",
  136.             noicon, "V", nomark, plain;
  137.         "Clear",
  138.             noicon, nokey, nomark, plain
  139.     }
  140. };
  141.  
  142. resource 'MENU' (mLight, preload) {
  143.     mLight, textMenuProc,
  144.     NoItems,                /* disable everything, program does the enabling */
  145.     enabled, "Traffic",
  146.      {
  147.         "Red Light",
  148.             noicon, nokey, nomark, plain;
  149.         "Green Light",
  150.             noicon, nokey, nomark, plain
  151.     }
  152. };
  153.  
  154.  
  155. /* this ALRT and DITL are used as an About screen */
  156.  
  157. resource 'ALRT' (rAboutAlert, purgeable) {
  158.     {40, 20, 160, 290},
  159.     rAboutAlert,
  160.     { /* array: 4 elements */
  161.         /* [1] */
  162.         OK, visible, silent,
  163.         /* [2] */
  164.         OK, visible, silent,
  165.         /* [3] */
  166.         OK, visible, silent,
  167.         /* [4] */
  168.         OK, visible, silent
  169.     }
  170. };
  171.  
  172. resource 'DITL' (rAboutAlert, purgeable) {
  173.     { /* array DITLarray: 5 elements */
  174.         /* [1] */
  175.         {88, 180, 108, 260},
  176.         Button {
  177.             enabled,
  178.             "OK"
  179.         },
  180.         /* [2] */
  181.         {8, 8, 24, 214},
  182.         StaticText {
  183.             disabled,
  184.             "Simple Sample (Traffic Light)"
  185.         },
  186.         /* [3] */
  187.         {32, 8, 48, 237},
  188.         StaticText {
  189.             disabled,
  190.             "Copyright © 1989 Apple Computer"
  191.         },
  192.         /* [4] */
  193.         {56, 8, 72, 136},
  194.         StaticText {
  195.             disabled,
  196.             "Brought to you by:"
  197.         },
  198.         /* [5] */
  199.         {80, 24, 112, 167},
  200.         StaticText {
  201.             disabled,
  202.             "Macintosh Developer  Technical Support"
  203.         }
  204.     }
  205. };
  206.  
  207.  
  208. /* this ALRT and DITL are used as an error screen */
  209.  
  210. resource 'ALRT' (rUserAlert, purgeable) {
  211.     {40, 20, 120, 260},
  212.     rUserAlert,
  213.     { /* array: 4 elements */
  214.         /* [1] */
  215.         OK, visible, silent,
  216.         /* [2] */
  217.         OK, visible, silent,
  218.         /* [3] */
  219.         OK, visible, silent,
  220.         /* [4] */
  221.         OK, visible, silent
  222.     }
  223. };
  224.  
  225.  
  226. resource 'DITL' (rUserAlert, purgeable) {
  227.     { /* array DITLarray: 3 elements */
  228.         /* [1] */
  229.         {50, 150, 70, 230},
  230.         Button {
  231.             enabled,
  232.             "OK"
  233.         },
  234.         /* [2] */
  235.         {10, 60, 30, 230},
  236.         StaticText {
  237.             disabled,
  238.             "Sample - Error occurred!"
  239.         },
  240.         /* [3] */
  241.         {8, 8, 40, 40},
  242.         Icon {
  243.             disabled,
  244.             2
  245.         }
  246.     }
  247. };
  248.  
  249.  
  250. resource 'WIND' (rWindow, preload, purgeable) {
  251.     {60, 40, 290, 160},
  252.     noGrowDocProc, visible, noGoAway, 0x0, "Traffic"
  253. };
  254.  
  255. resource 'RECT' (rStopRect, preload, purgeable) {
  256.     {10, 10, 110, 110}
  257. };
  258.  
  259. resource 'RECT' (rGoRect, preload, purgeable) {
  260.     {120, 10, 220, 110}
  261. };
  262.  
  263.  
  264. /* here is the quintessential MultiFinder friendliness device, the SIZE resource */
  265.  
  266. resource 'SIZE' (-1) {
  267.     dontSaveScreen,
  268.     acceptSuspendResumeEvents,
  269.     enableOptionSwitch,
  270.     canBackground,                /* we can background; we don't currently, but our sleep value */
  271.                                 /* guarantees we don't hog the Mac while we are in the background */
  272.     multiFinderAware,            /* this says we do our own activate/deactivate; don't fake us out */
  273.     backgroundAndForeground,    /* this is definitely not a background-only application! */
  274.     dontGetFrontClicks,            /* change this is if you want "do first click" behavior like the Finder */
  275.     ignoreChildDiedEvents,        /* essentially, I'm not a debugger (sub-launching) */
  276.     not32BitCompatible,            /* this app should not be run in 32-bit address space */
  277.     reserved,
  278.     reserved,
  279.     reserved,
  280.     reserved,
  281.     reserved,
  282.     reserved,
  283.     reserved,
  284.     kPrefSize * 1024,
  285.     kMinSize * 1024    
  286. };
  287.